/**
 * 
 */
package com.base.myproject.server;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.Random;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 心跳
 * 
 * @author zgw 2009-7-7 下午10:44:54 javazgw@gmail.com
 */
public class HearBeatServletX extends HttpServlet {
	Random r = new Random();
	
	protected void processRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		// response.setContentType("application/json;charset=UTF-8");
		response.setContentType("multipart/form-data;charset=UTF-8");
		PrintWriter out = response.getWriter();
		request.setCharacterEncoding("utf-8");
		Enumeration enumeration = request.getParameterNames();

	/*	while (enumeration.hasMoreElements()) {
			String eeee = "" + enumeration.nextElement();
			System.out.print("e=" + eeee + "=");
			System.out.println(request.getParameter("" + eeee));
		}*/

		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		if(Task.getinstance().isIschange() )
		{
			
			out.print("reload");
		}
				 
	/*	int i = r.nextInt(4);
		System.out.println(i);
		if (i == 3) {
			out.print("reload");
			
			
		} else {
			out.print("zgw");
		}*/
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		processRequest(request, response);
	}

	/**
	 * Handles the HTTP <code>POST</code> method.
	 * 
	 * @param request
	 *            servlet request
	 * @param response
	 *            servlet response
	 * @throws ServletException
	 *             if a servlet-specific error occurs
	 * @throws IOException
	 *             if an I/O error occurs
	 */
	@Override
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		processRequest(request, response);
	}

}
